import {createRouter, createWebHistory} from 'vue-router'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            name: 'layout',
            component: () => import("@/views/layout/layout.vue"),
            children: [
                {
                    path: '/help',
                    name: 'help',
                    meta: {title: '帮助'},
                    component: () => import("@/views/help/help.vue"),
                }
            ]
        },
    ],
})

router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title + '';
    } else {
        document.title = '';
    }
    next();
});

export default router
